<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
</head>
<body>
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <div class="layui-row">
      </div>
      <div class="row">
        <form class="layui-form" lay-filter="myform" id="myform">
          <fieldset id="fs0">
            <legend id="lg0">学院/系</legend>
          </fieldset>
          <hr>
          <fieldset id="fs1">
            <legend id="lg1">专业</legend>
          </fieldset>
          <hr>
          <fieldset id="fs2">
            <legend id="lg2">科目</legend>
          </fieldset>
          <hr>
          <div class="layui-form-item">
            <label class="layui-form-label">学生类型</label>
            <div class="layui-input-inline">
              <select name="studentType" id="studentType"></select>
            </div>

            <label class="layui-form-label">学期</label>
            <div class="layui-input-inline">
              <select name="semester" id="semester"></select>
            </div>

          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">中 / 英文</label>
            <div class="layui-input-inline">
              <select name="lg" id="lg"></select>
            </div>
            <label class="layui-form-label">考试阶段</label>
            <div class="layui-input-inline">
              <select name="testPhase" id="testPhase"></select>
            </div>
            <label class="layui-form-label">考试方式</label>
            <div class="layui-input-inline">
              <select name="testType" id="testType"></select>
            </div>
            <label class="layui-form-label">A/B/C卷</label>
            <div class="layui-input-inline">
              <select name="paperType" id="paperType"></select>
            </div>

          </div>
          <div class="layui-form-item">
            <br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="color:red;font-weight: bolder">提示：如果考生年级不选，将不会生成组卷记录</div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">考生年级</label>
            <div class="layui-input-inline">
              <select name="grade" id="grade"></select>
            </div>
            <label class="layui-form-label">学年</label>
            <div class="layui-input-inline">
              <select name="gradeYear" id="gradeYear"></select>
            </div>
            <label class="layui-form-label">考试时长</label>
            <div class="layui-input-inline">
              <input type="number" name="howlong" id="howlong" autocomplete="off" class="layui-input">
            </div><div class="layui-form-mid">分钟</div>
          </div>

        </form>
      </div>
    </div>
  </div>
</div>

<script th:inline="none"></script>
<script>
  layui.use(['table','form','element'], function(){
    var table = layui.table,
            form = layui.form;
    createSelect("test-phase","testPhase",form,'','请选择');
    createSelect("paper-type","paperType",form,'','请选择');
    createSelect("test-type","testType",form,1,'请选择');
    createSelect("question-source","source",form,1,'请选择');
    createSelect("question-difficulty","difficulty",form,1,'请选择');
    createSelect("content-type","contentType",form,1,'请选择');
    createSelect("paper-lg","lg",form,1,'请选择');
    createSelect("semester","semester",form,'','请选择');
    createSelect("student-type","studentType",form,'','请选择');
    select('grade/getPageList?limit=30&page=1' , 'grade',form,'name','id')
    select('pian/getPageList?limit=30&page=1' , 'pianId',form,'name','id')
    select('knowledgePoint/getPageList?limit=1000&page=1' , 'knowledge1',form,'name','id')
    select('college/getPageList?limit=30&page=1' , 'collegeId',form,'name','id')
    select('libCategory/getPageList?limit=30&page=1' , 'categoryId',form,'name','id')
    select('major/getPageList?limit=30&page=1' , 'majorId',form,'name','id')
    select('gradeYear/getPageList?limit=30&page=1' , 'gradeYear',form,'name','id')
    axios.get("major/getPageList?limit=100&page=1").then(res=>{
        let data = res.data.data;
        let f1 = $("#fs1");
        for(var i=0;i<data.length;i++){
          let name = data[i].name;
          let id = data[i].id;
          f1.append($('<input type="radio" name="major">').val(id).attr("title",name));
        }
        form.render();
    })
    axios.get("college/getPageList?limit=100&page=1").then(res=>{
        let data = res.data.data;
        let f1 = $("#fs0");
        for(var i=0;i<data.length;i++){
          let name = data[i].name;
          let id = data[i].id;
          f1.append($('<input type="radio" name="college">').val(id).attr("title",name));
        }
        form.render();
    })
    axios.get("libCategory/getPageList?limit=100&page=1").then(res=>{
      let data = res.data.data;
      let f2 = $("#fs2");
      for(var i=0;i<data.length;i++){
        let name = data[i].name;
        let id = data[i].id;
        f2.append($('<input type="radio" name="category">').val(id).attr("title",name));
      }
      form.render();
    })
    window.getIds = function (){
      let r1 = $("#fs1 :radio:checked");
      let r2 = $("#fs2 :radio:checked");
      let r0 = $("#fs0 :radio:checked");
      return {major:r1.val(),category:r2.val(),lg :$("#lg").val(),testPhase:$("#testPhase").val(),grade:$("#grade").val(),
        studentType:$("#studentType").val(),
        testType:$("#testType").val(),howlong:$("#howlong").val(),
        paperType:$("#paperType").val(),collegeId:r0.val(),gradeYear:$("#gradeYear").val(),semester:$("#semester").val()};
    }
    var $ = layui.$, active = {
      query: function(){

        table.reload("main-table",{where:{name:$("#name").val()}})
      },
      resetBtn:function () {
        $("#btReset").click();

      }
    };
    $('.layui-form .layui-btn').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });

  });

</script>
</body>
</html>